import sys
import os

verinfo = [
    ['PRODUCT_VERSION_MAJOR', '7'],
    ['PRODUCT_VERSION_MINOR', '10'],
    ['PRODUCT_VERSION_RELEASE', '1'],
    ['PRODUCT_RELEASE_STAGE', '"alpha"'],
    ['PRODUCT_BRIEF_NAME', '"Daodict"'],
    ['PRODUCT_UNIX_NAME', '"daodict"'],
    ['PRODUCT_EMAIL', '"support@daodict.com"'],
    ['PRODUCT_EDITION', '"Community Edition"'],
    ['PRODUCT_GUID_STRING', '"{B7733B2B-A475-40DD-ADC2-6B9B5C1DF199}"'],
    ['PRODUCT_GUID', '"{{B7733B2B-A475-40DD-ADC2-6B9B5C1DF199}"'],
    
    ['PRODUCT_VERSION_NUMBER', '"7.10.1"'],
    ['PRODUCT_VERSION_STRING', '"7.10 alpha"'],
    ['PRODUCT_FULL_NAME', '"Daodict (Community Edition)"'],
    ['PRODUCT_FULL_VERSION_STRING', '"Daodict (Community Edition) 7.10 alpha"'],
    
    ['PRODUCT_GROUP_NAME', '"Daodict (Community Edition) 7.10 alpha"'],
    ['PRODUCT_SETUP_EXE', '"Daodict (Community Edition) 7.10 alpha-Setup"'],
    
    ['PRODUCT_COMPANY', '"daodict.com"'],
    ['PRODUCT_DEVELOPERS', '"Brang.Young, Contributors"'],
    ['PRODUCT_LICENSE', '"GPL 3.0"'],
    ['PRODUCT_COMPANY_URL', '"http://www.daodict.com"'],
    ['PRODUCT_URL', '"http://www.daodict.com/dict"'],
    ['PRODUCT_DESCRIPTION', '"Daodict is an open source,multi-platform and multi-language computer dictionary, provide large number of dictionaries."'],
    
    ['PRODUCT_COPYRIGHT_SHORT', '"Copyright (C) 2007 daodict.com"'],
    ['PRODUCT_COPYRIGHT', '"Copyright (C) 2007 daodict.com, Brang.Young, Contributors. All Rights Reserved."'],
    ['PRODUCT_MUTEX', '"http://www.daodict.com/dict"'],
    
    ['PRODUCT_CONFIG_SUBDIR', '".daodict"'],
    
    
    ['DAODICT_BRIEF_NAME', '"Daodict"'],
    ['DAODICT_UNIX_NAME', '"daodict"'],
    ['BGL2TXT_UNIX_NAME', '"bgl2txt"'],
    ['DICTPACK_UNIX_NAME', '"dictpack"'],
    ['TXT2DICT_UNIX_NAME', '"txt2dict"'],
]

OUTPUT_DIR = os.path.dirname(sys.argv[0])

def gen_c_header() :
    header_f = open(os.path.join(OUTPUT_DIR,'verinfo.h'), 'w+')
    
    header_f.write("// This file is generated by gen_verinfo.py,\n")
    header_f.write("// DO NOT edit this file manually if you don't know what are you doing.\n\n")
    header_f.write('#pragma once\n\n')
    
    global verinfo;
    
    for info in verinfo :
        line = '#define ' + info[0] + ' ' + info[1] + '\n'
        
        header_f.write(line)
        
    header_f.write('\n')
    header_f.close()
    
def gen_innosetup_script() :
    iss_f = open(os.path.join(OUTPUT_DIR,'verinfo.iss'), 'w+')
    
    global verinfo;
    
    iss_f.write("; This file is generated by gen_verinfo.py,\n")
    iss_f.write("; DO NOT edit this file manually if you don't know what are you doing.\n\n")
    
    for info in verinfo :
        line = '#define ' + info[0] + ' ' + info[1] + '\n'
        
        iss_f.write(line)
        
    iss_f.write('\n')
    iss_f.close()
    
if __name__=="__main__" :
    gen_c_header()
    gen_innosetup_script()
    